package grammarLearn

import "fmt"

type IInterfaceTest interface {
	RoundID() string
}

func getIInterfaceTest() IInterfaceTest {
	return nil
}

func assignNilToInterfance() {
	result := getIInterfaceTest()
	if result == nil {
		fmt.Println("run in if result == nil") // 会执行到这里
	}
	fmt.Println("run in assignNilToInterfance end")
}

func TestChangeAttr2BianLiangFromInterface() {
	type assSt struct {
		ID string
	}

	oriObj := assSt{
		ID: "abc",
	}
	var ivar interface{} = oriObj

	//ivar.(assSt).ID = "eee" // cannot assign to ivar.(assSt).ID (neither addressable nor a map index expression) (exit status 1)

	fmt.Println(ivar) //{abc}

	var iRefVar interface{} = &oriObj
	iRefVar.(*assSt).ID = "eee"
	fmt.Println(iRefVar) //&{eee}
	fmt.Println(oriObj)  //{eee}
}
